﻿@model DietPlanning.Models.UserDietModels
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutUser.cshtml";
}


     
      <p> @Html.ActionLink("Set up new Diet", "CreateDiet", "Account")</p>
<h4>
    Danh sách các thực đơn của bạn</h4>
<table class="table table-bordered table-hover table-striped">
    <tr>
        <th>
            DietName
        </th>
        <th>
            Time to Start
        </th>
        <th>
            Time to End
        </th>
        <th>
            Status
        </th>
        <th>
            Detail
        </th>
    </tr>
    @for (int i = 0; i < Model.Diet.Count(); i++)
    {
        DietPlanning.Models.Diet item = Model.Diet.ElementAt(i);
        if (i % 2 == 0)
        {
            @:<tr class="error" id="item-@item.DietID">
        }
        else
        {
            @:<tr class="warning" id="item-@item.DietID">
        }
        <td>
            @Html.DisplayFor(modelItem => item.DietName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DateTimeBegin)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DateTimeEnd)
        </td>
        <td>
            @if (item.isNew == 0)
            {
                <text> Old </text>
            }
            else
            {
                <text> New </text>
            }
        </td>
        <td>
            @if (item.DateTimeBegin != null)
            {
                @Html.ActionLink("DietDetail", "DietDetail", new { id = item.DietID,day =(item.DateTimeBegin.Value.DayOfYear - DateTime.Now.DayOfYear) })
            }

        </td>
        @:</tr>
    }
</table>

